<?php
//
//	file: includes/wpu/class_wpu_display.php
//	begin: 09/05/2007
//	$Author: christopher $
//	$Revision: 14 $
//	$Date: 2007-10-08 14:55:03 +0000 (Mon, 08 Oct 2007) $
//	license: http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
//
//	based on : attachment_mod copyright (c) 2002 Meik Sievertsen (acydburn)
//

if ( !defined('IN_PHPBB') )
{
	die('Hacking attempt');
	exit;
}

class wpu_display extends plug_ins
{
	var $posts;

	function title_display()
	{
		$this->posts = false;
	}

	function start()
	{
		global $user;

		$user->pool_fields[] = 'user_wpublog_id';
		$user->pool_fields[] = 'user_wpuint_id';
	}

	function set_posts(&$posts)
	{
		$this->posts = &$posts;
	}

	function display($post_id=0, $tpl_switch='')
	{
		global $db, $config, $user, $template, $wpSettings, $requester;

		if(!$post_id)
		{
			return;
		}

		// first, we get data for the specific row
		$postrow = $this->posts->data[intval($post_id)];
		$poster_id = isset($user->pool[ $postrow['poster_id'] ]) ? $postrow['poster_id'] : ANONYMOUS;
		$tpl_data = array();
		$blog_img = '';

		// then, we play with the poster block for that user
		if  ( $wpSettings != FALSE )
		{
			if ($wpSettings['buttonsPost'] && $user->pool[$poster_id]['user_wpuint_id'])
			{
				$blog_uri = append_sid($wpSettings['blogsUri'] . "?author=" . $user->pool[$poster_id]['user_wpuint_id']);
				$blog_img = '<a href="' . $blog_uri . '"><img src="' . $user->img('icon_wpu_blog') . '" alt="' . $user->lang('Blog') . '" title="' . $user->lang('Blog') . '" border="0" /></a>';
			}
		}

		$tpl_data['BLOG_IMG'] = $blog_img;

		if ( empty($tpl_switch) )
		{
			$template->assign_vars($tpl_data);
		}
		else
		{
			$template->assign_lastblock_vars($tpl_switch, $tpl_data);
		}

		return;
	}
}

?>